/* The file is saved in UTF-8 codepage.
 * Check: «Stereotype», Section mark-§, Copyright-©, Alpha-α, Beta-β, Smile-☺
 */
package cz.pecinovsky.english.lootp._115_;

import cz.pecinovsky.english.lootp._parents._ITrafficLight_116_119;

import cz.pecinovsky.english.lootp.manager.IPaintable;
import cz.pecinovsky.english.lootp.manager.Painter;
import cz.pecinovsky.english.lootp.manager.Rectangle;

import cz.pecinovsky.english.lootp.utility.NamedColor;

// %I+ =116z
//import cz.pecinovsky.english.lootp.shapes.Ellipse;
// %I-
// %I+ <119
//import cz.pecinovsky.english.lootp.shapes.Rectangle;
// %I-

import cz.pecinovsky.english.lootp.utility.IO;


import cz.pecinovsky.english.lootp._115_.Light_117_119.Light;



//import cz.pecinovsky.english.lootp._115_.TrafficLight_116_119.TrafficLight;
////////////////////////////////////////////////////////////////////////////////
//%%+  +++++ End of ignored starting test - place for imports +++++

//%X+ xxxxx Start of the ovejumped text with declaration of the envelope xxxxx
/*******************************************************************************
 *<pre>
 * Previous:  No - this is a newly defined class
 * Following: No
 *
 * Project  016z_02_Tvary
 *   + Two constructors
 *
 *</pre>
 *
 * @author Rudolf PECINOVSKÝ
 * @version 6.03.2017 — 2010-11-08
 */
/*******************************************************************************
 *<pre>
 * Předchozí:   Není - toto_je_nově_definovaná_třída
 *
 * Následující: oopnz._115_._120_Semafor_
 *
 * Projekt  Ppp
 *   + Přidáno
 *   - Odebráno
 *   ~ Změněno
 *</pre>
 *
 * @author Rudolf PECINOVSKÝ
 * @version 6.03.2017 — 2010-11-08
 */
public class TrafficLight_116_119
{    private TrafficLight_116_119() {}   static
////////////////////////////////////////////////////////////////////////////////
//%X- ----- End of the ovejumped text with declaration of the envelope -----


//%I+ <119
//public class TrafficLight
//%I-
//%A+ >119
public class TrafficLight implements IPaintable
//%A-
//%A+ <0
        ,   _ITrafficLight_116_119
//%A-
{
//%A+ >118
    private Rectangle box;
    private Light     redLight;
    private Light     amberLight;
    private Light     greenLight;


//%A-
    public TrafficLight()
    {
//%I+ =116z
//        new Rectangle(0,   0, 50, 150, NamedColor.BLACK);
//        new Ellipse  (0,   0, 50,  50, NamedColor.RED);
//        new Ellipse  (0,  50, 50,  50, NamedColor.YELLOW);
//        new Ellipse  (0, 100, 50,  50, NamedColor.GREEN);
//%I-
//%I+ =117z
//        new Rectangle(0,   0, 50, 150, NamedColor.BLACK);
//        new Light    (0,   0, NamedColor.RED);
//        new Light    (0,  50, NamedColor.YELLOW);
//        new Light    (0, 100, NamedColor.GREEN);
//%I-
//%A+ >118
        box        = new Rectangle(0,   0, 50, 150, NamedColor.BLACK);
        redLight   = new Light    (0,   0, NamedColor.RED);
        amberLight = new Light    (0,  50, NamedColor.YELLOW);
        greenLight = new Light    (0, 100, NamedColor.GREEN);
//%A-
    }
//%A+ >117


    public TrafficLight(int x, int y)
    {
//%A-
//%I+ =117z
//        new Rectangle(x, y+  0,  50, 150, NamedColor.BLACK);
//        new Light  (x, y+  0, NamedColor.RED);
//        new Light  (x, y+ 50, NamedColor.YELLOW);
//        new Light  (x, y+100, NamedColor.GREEN);
//%I-
//%A+ >118
        box        = new Rectangle(x, y+  0,  50, 150, NamedColor.BLACK);
        redLight   = new Light    (x, y+  0, NamedColor.RED);
        amberLight = new Light    (x, y+ 50, NamedColor.YELLOW);
        greenLight = new Light    (x, y+100, NamedColor.GREEN);
//%A-
//%A+ >117
    }


    public TrafficLight(int x, int y, NamedColor boxColor)
    {
//%A-
//%I+ =117z
//        new Rectangle(x, y+  0,  50, 150, boxColor);
//        new Light    (x, y+  0, NamedColor.RED);
//        new Light    (x, y+ 50, NamedColor.YELLOW);
//        new Light    (x, y+100, NamedColor.GREEN);
//    }
//%I-
//%A+ >118
        box        = new Rectangle(x, y+  0,  50, 150, boxColor);
        redLight   = new Light    (x, y+  0, NamedColor.RED);
        amberLight = new Light    (x, y+ 50, NamedColor.YELLOW);
        greenLight = new Light    (x, y+100, NamedColor.GREEN);
    }


//%A-
//%A+ <"
    @Override
//%A-
//%A+ >118
    public void stop()
    {
        redLight   .switchOn();
        amberLight .switchOff();
        greenLight .switchOff();
    }


//%A-
//%A+ <"
    @Override
//%A-
//%A+ >118
    public void getReady()
    {
        redLight   .switchOn();
        amberLight .switchOn();
        greenLight .switchOff();
    }


//%A-
//%A+ <"
    @Override
//%A-
//%A+ >118
    public void go()
    {
        redLight   .switchOff();
        amberLight .switchOff();
        greenLight .switchOn();
    }


//%A-
//%A+ <"
    @Override
//%A-
//%A+ >118
    public void attention()
    {
        redLight   .switchOff();
        amberLight .switchOn();
        greenLight .switchOff();
    }


//%A-
//%A+ <"
    @Override
//%A-
//%A+ >118
    public void allLightsOff()
    {
        redLight   .switchOff();
        amberLight .switchOff();
        greenLight .switchOff();
    }


//%A-
//%A+ <"
    @Override
//%A-
//%A+ >118
    public void cycle(int stop, int getReady, int go, int attention,
                      int lightsOff)
    {
        stop();         IO.pause(stop);
        getReady();     IO.pause(getReady);
        go();           IO.pause(go);
        attention();    IO.pause(attention);
        allLightsOff();    IO.pause(lightsOff);
    }


//%A-
//%A+ <"
    @Override
//%A-
//%A+ >118
    public void cycle()
    {
        cycle(500, 500, 500, 500, 0);
    }
//%A-
//%A+ >119


    /***************************************************************************
     * Prostřednictvím dodaného kreslítka vykreslí obraz své instance.
     *
     * @param painter Painter, které nakreslí instanci
     */
    @Override
    public void paint(Painter painter)
    {
        box.paint(painter);
        redLight.paint(painter);
        amberLight  .paint(painter);
        greenLight .paint(painter);
    }
//%A-
    }

//%%- ---- Start of the ovejumped text with closing of the envelope ----
////////////////////////////////////////////////////////////////////////////////

//== TESTING CLASSES AND METHODS ===============================================
//
//    /***************************************************************************
//     * Test method.
//     */
//    public static void test()
//    {
//        new TrafficLight();
//        new TrafficLight(100, 100);
//        new TrafficLight(200,  50, NamedColor.HNĚDÁ);
////        System.exit(0);
//    }
//    /** @param args Parametry příkazového řádku - nepoužívané. */
//    public static void main(String[] args)  {  test();  }
}
